package com.yan.springbootstudy.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.DispatcherServlet;

import com.yan.springbootstudy.common.filter.DataOperationFilter;


/**
 * 
 * @Title: WebFilterConfig.java
 * @Package com.yan.springbootstudy.config
 * @Description: web环境配置，原web.xml的配置
 * @author yan
 * @date 2017年8月30日
 * @version V1.0
 */
@Configuration
@Order(3)
public class WebFilterConfig {
    @Bean
    public FilterRegistrationBean dataOperationFilterRegistration() {
        FilterRegistrationBean dataOperationRegistration = new FilterRegistrationBean(new DataOperationFilter());
        dataOperationRegistration.addUrlPatterns("*.do");
        return dataOperationRegistration;
    }
    
    @Bean
    public ServletRegistrationBean dispatcherRegistration(DispatcherServlet dispatcherServlet) {  
        ServletRegistrationBean registration = new ServletRegistrationBean(dispatcherServlet);  
        registration.getUrlMappings().clear();  
        registration.addUrlMappings("*.do");  
        return registration;  
    }  
}
